
<!doctype html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/favicon.ico">
    <link rel="canonical" href="https://getbootstrap.com/docs/3.4/examples/signin/">

    <title>基于Django的气象数据采集和分析</title>

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/examples/signin/signin.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>
        <form class="form-signin">
            <div class="center">
                <h1>
                    <i class="icon-leaf green"></i>
                    <span class="red">Django</span>
                    <span class="white">Application</span>
                </h1>
                <h4 class="blue">&copy; 基于Django的气象数据采集和分析</h4>
            </div>
            <h2 class="form-signin-heading">请登录</h2>
            <label for="username" class="sr-only">用户名</label>
            <input type="text" id="username" class="form-control" placeholder="用户名" required autofocus>
            <label for="password" class="sr-only">密码</label>
            <input type="password" id="password" class="form-control" placeholder="密码" required>
            <button class="btn btn-lg btn-primary btn-block" type="button" id="login">登录</button>
            <button class="btn btn-lg btn-primary btn-block" type="button" id="register">注册</button>
        </form>

    </div> <!-- /container -->


    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.4/assets/js/ie10-viewport-bug-workaround.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>

    <script type="text/javascript">
        // 注册
        $("#register").click(function() {
            window.location.href="register.html";
        });
        // 登陆
        $("#login").click(function() {
            var username = $("#username").val();
            var password = $("#password").val();
            $.ajax({
                 type: "post",
                 url: "http://127.0.0.1:8082/api/user/login",
                 cache: false,
                 data: {
                    username : username,
                    password : password
                 },
                 success : function(res) {
                    if(res.status=="ok"){
                        alert("登陆成功");
                        window.location.href="user.html";
                    } else{
                        alert(res.msg)
                    }
                }
            });

        });
    </script>
  </body>
</html>
